package com.example.guavaSrudy.basicObjectUtilities;



import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ComparisonChain;
import lombok.Data;

import static com.google.common.base.Preconditions.*;

public class GuavaBasicUse {

    public static void main(String[] args) {
//        Book book = new Book();
//        book.author = "bobo";
//        book.title = "bobo";
//        book.publisher = "bobo";
//        book.isbn = "bobo";
//        book.price = 250.0;
//        System.out.println(book);
        String value = MoreObjects.firstNonNull(null,"default value");
        System.out.println(value);

    }
    public static class Book implements Comparable<Book> {

        private String author;
        private String title;
        private String publisher;
        private String isbn;
        private double price;



        @Override
        public int compareTo(Book o) {

            return ComparisonChain.start()
                    .compare(this.title, o.getTitle())
                    .compare(this.author, o.getAuthor())
                    .compare(this.publisher, o.getPublisher())
                    .compare(this.isbn, o.getIsbn())
                    .compare(this.price, o.getPrice())
                    .result();
        }

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this)
                    .omitNullValues()
                    .add("title", title)
                    .add("author", author)
                    .add("publisher", publisher)
                    .add("price",price)
                    .add("isbn", isbn).toString();
        }
        @Override
        public int hashCode() {
            return Objects.hashCode(title, author, publisher, isbn);
        }

        public String getAuthor() {
            return author;
        }

        public void setAuthor(String author) {
            this.author = author;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getPublisher() {
            return publisher;
        }

        public void setPublisher(String publisher) {
            this.publisher = publisher;
        }

        public String getIsbn() {
            return isbn;
        }

        public void setIsbn(String isbn) {
            this.isbn = isbn;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }
    }

    }
